package com.moleq.models;

import com.moleq.db.DatabaseSchema;


public class TaxSetting {
//	CREATE TABLE t_tax_setting
//	(tx_no INTEGER NOT NULL,
//	tx_rate numeric(8,3) Default 0 NOT NULL,
//	tx_start_amt numeric(8,3) NULL,
//	tx_plus_round numeric(8,4) NULL,
//	tx_vat integer Default 0 NOT NULL,
//	tx_by_line integer Default 0 NOT NULL,
//	create_datetime varchar(14) NOT NULL,
//	update_datetime varchar(14) NOT NULL,
//	PRIMARY KEY (tx_no));
	
	private int tx_no; 
	private double tx_rate; 
	private double tx_start_amt; 
	private double tx_plus_round; 
	private boolean tx_vat; 
	private boolean tx_by_line; 
	private String create_datetime;
	private String update_datetime;
    
	
	public TaxSetting(){}
	public TaxSetting(int _tx_no,double _tx_rate,double _tx_start_amt,double _tx_plus_round,boolean _tx_by_line,boolean _tx_vat){
		this.tx_no = _tx_no;
		this.tx_rate = _tx_rate;
		this.tx_start_amt = _tx_start_amt;
		this.tx_plus_round = _tx_plus_round;
		this.tx_vat = _tx_vat;
		this.tx_by_line = _tx_by_line;
	}
	
	public int getTx_no() {
		return tx_no;
	}
	public void setTx_no(int tx_no) {
		this.tx_no = tx_no;
	}
	public double getTx_rate() {
		return tx_rate;
	}
	public void setTx_rate(double tx_rate) {
		this.tx_rate = tx_rate;
	}
	public double getTx_start_amt() {
		return tx_start_amt;
	}
	public void setTx_start_amt(double tx_start_amt) {
		this.tx_start_amt = tx_start_amt;
	}
	public double getTx_plus_round() {
		return tx_plus_round;
	}
	public void setTx_plus_round(double tx_plus_round) {
		this.tx_plus_round = tx_plus_round;
	}
	public boolean isTx_vat() {
		return tx_vat;
	}
	public void setTx_vat(boolean tx_vat) {
		this.tx_vat = tx_vat;
	}
	public boolean isTx_by_line() {
		return tx_by_line;
	}
	public void setTx_by_line(boolean tx_by_line) {
		this.tx_by_line = tx_by_line;
	}
	public String getCreate_datetime() {
		return create_datetime;
	}
	public void setCreate_datetime(String create_datetime) {
		this.create_datetime = create_datetime;
	}
	public String getUpdate_datetime() {
		return update_datetime;
	}
	public void setUpdate_datetime(String update_datetime) {
		this.update_datetime = update_datetime;
	}
	
	public String getTx_vat(){
		return isTx_vat()?"1":"0";
	}
	public String getTx_by_line(){
		return isTx_by_line()?"1":"0";
	}
	
	public String toMGData(String Action) {
		String Result = Action + "|" + DatabaseSchema.TaxSetting.SCHEMA_NAME
				+ "|(" + getTx_no() + "," + getTx_rate() + "," + getTx_start_amt() + ","
				+ getTx_plus_round() + "," + getTx_vat() + "," + getTx_by_line() + "," 
				+ CheckNull(getCreate_datetime()) + "," + CheckNull(getUpdate_datetime())+ ")";
		return Result;
	}
	
	public String CheckNull(String value){
		if(value == null){
			return null;
		}else{
			return "'" + value + "'";
		}
	}
}
